/**
 *
 */
package net.zantetu.matomeroid.util;

import java.io.IOException;
import java.util.List;

import net.zantetu.matomeroid.dto.TabDto;
import net.zantetu.matomeroid.sax.TabHandler;

import org.ccil.cowan.tagsoup.Parser;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

import android.content.Context;

/**
 * @author aono_masashi
 *
 */
public class ScripingParser {

	public static List<TabDto> parseHTML(Context context, String path){
		TabHandler handler = new TabHandler();
		Parser parser = new Parser();
		parser.setContentHandler(handler);
		InputSource is = null;
		try {
			is = new InputSource(context.getAssets().open(path));
			is.setEncoding("UTF-8");

			parser.parse(is);

			return handler.getResult();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (SAXException e) {
			e.printStackTrace();
		}
		return null;
	}
}
